<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    const pm = function(urls){
        return new Promise((resolved,rejected)=>{
            const xhr = new XMLHttpRequest();
            xhr.open("get",urls);
            // 设置请求内容格式
            xhr.responseType ="json";
			xhr.setRequestHeader("Accept","application/json");
            xhr.onreadystatechange = getDatas;
            xhr.send()
            function  getDatas(){
                // console.log(xhr.readyState);
                if(xhr.readyState==4){
                    if(this.status==200){
                        resolved(xhr.response)
                    }else{
                        rejected("失败")
                    }
                    
                }
            }
        })
    }

    let obj = pm("http://39.104.16.173:8081/home/swiper");
    obj.then(res=>{
        console.log(res);
    })

</script>
</html>